package com.cloud.code.牛客网;

import java.util.*;

public class TestCh {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            int n = sc.nextInt();
            int[] zhong = new int[n];
            for (int i = 0; i < n; i++) {
                zhong[i] = sc.nextInt();
            }

            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
            }
            Set<Integer> sets = new HashSet<>();
            sets.add(0);
            for (int i = 0; i < n; i++) {
                List<Integer> list = new ArrayList<>(sets);
                for (int j = 1; j <= nums[i]; j++) {
                    for (int k = 0; k < list.size(); k++) {
                        sets.add(list.get(k) + zhong[i] * j);
                    }
                }
            }

            System.out.println(sets.size());


        }
    }

}